﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Data;
using System.Data.SqlClient;

using SIPO.Library;
using SIPO.Library.DomainObject.Administration.Catalog;
using SIPO.Library.DomainObject.Administration.UserManagement;
using SIPO.Library.DomainObject.Transaction;
using SIPO.Library.Enum;
using SIPO.Library.Interfaces;

namespace SIPO.Library.DataAccess.Transaction
{
   public partial class recDendaRepo 
    { private string connectionString;
        public recDendaRepo(string ConnectionString)
        {
            connectionString = ConnectionString;
        }
        
        public bool Save(string userLogin)
        {
            bool result = false;
            using (SqlConnection conn = new SqlConnection(connectionString))
            {
                conn.Open();
                SqlTransaction txn = conn.BeginTransaction();
                try
                {
                    string strExecuteSp = "[dbo].[SP_GenDenda]";
                    SqlCommand cmdExecuteSp = new SqlCommand(strExecuteSp, conn);
                    cmdExecuteSp.CommandType = CommandType.StoredProcedure;
                    cmdExecuteSp.CommandTimeout = 0;
                    cmdExecuteSp.Transaction = txn;
                    cmdExecuteSp.ExecuteNonQuery();
                    cmdExecuteSp.Dispose();

                    result = true;
                    txn.Commit();
                }
                catch (Exception ex)
                {
                    txn.Rollback();
                    throw (ex);
                }
                finally
                {
                    if (conn.State == ConnectionState.Open) conn.Close();
                }

            }
            return result;
        }
        
    }
}
